
local function connect(self)
    local port = Port.New();
    local line = Port.Connect(port, '127.0.0.1', 10000);
    Port.OnPacket(port, "PLAYER.on_packet", self)
    self.line = line
end



local function on_packet(self, msgid, pkt)
     local a = Pkt.ReadUtf(pkt); 
     print(a)
end


local function new()
    return {
    }
end

local function test_send(self)
    line = self.line
    Port.Send(line, 1234, "lujingwei", "123456")
end

local function test_timer_send(self)
    Timer.AddTimer(5, 1234, "PLAYER.on_test_timer_send", self) 
end
local count = 1;
local function on_test_timer_send(self, msgid)
    line = self.line
    Port.Send(line, msgid, "lujingwei", "123456")
    --print("on_timer"..self.cc);    
    count = count + 1;
    return 1;
end

PLAYER = {
    new = new,
    connect = connect,
    on_packet = on_packet,
    test_send = test_send,
    test = test,
    test_timer_send = test_timer_send,
    on_test_timer_send = on_test_timer_send,
}

p = PLAYER.new()
PLAYER.connect(p)
PLAYER.test_timer_send(p)




